home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 051-060 / amok58 / realconversions2 / lrctest.mod < prev    next >
Text File  |  1993-11-04  |  1KB  |  44 lines

  1. MODULE LRCTest; (* Test of module RealConversions2 *)
  2.  
  3.   IMPORT io,
  4.          RC:LongRealConversions2;
  5.  
  6.   VAR
  7.     r:LONGREAL;
  8.     ges,nach:LONGINT;
  9.     expo,left:BOOLEAN;
  10.     string:ARRAY 22 OF CHAR;  (* For 15 Digits -1.23456789123456E-123 *)
  11.     c:ARRAY 2 OF CHAR;
  12.  
  13. BEGIN
  14.   io.WriteString('Test of the procedures StringToReal() and RealToString()\n');
  15.   io.WriteString('The input-string is converted to a real-number and then\n');
  16.   io.WriteString('converted back to a string. Enter 0 to exit!\n\n');
  17.   io.WriteString('Scientific Notation (Y/N) ? ');
  18.   io.ReadString(c);
  19.   expo:=(CAP(c[0])='J') OR (CAP(c[0])='Y');
  20.   io.WriteString('Left justified? ');
  21.   io.ReadString(c);
  22.   left:=(CAP(c[0])='J') OR (CAP(c[0])='Y');
  23.   io.WriteString('Number of significant digits: ');
  24.   IF io.ReadInt(ges) THEN END;
  25.   io.WriteString('Digits behind the decimalpoint: ');
  26.   IF io.ReadInt(nach) THEN END;
  27.   REPEAT
  28.     io.WriteString('Input :');
  29.     io.ReadString(string);
  30.     io.WriteString('Output:');
  31.     RC.DeleteSpaces(string);
  32.     IF NOT RC.StringToReal(string,r) THEN
  33.       io.WriteString('Input-Error ')
  34.     END;
  35.     IF NOT RC.RealToString(r,string,SHORT(ges),SHORT(nach),expo,left) THEN
  36.       io.WriteString('String (22) is too small for this number ')
  37.     END;
  38.     io.WriteString(string);
  39.     io.WriteLn;
  40.   UNTIL r=0;
  41.   io.WriteLn;
  42.  
  43. END LRCTest.
  44.